package com.itheima.demo04.Supplier;

import java.io.InputStreamReader;
import java.util.function.Supplier;

public class Demo02Test {
    public static void main(String[] args) {
        int[] arr = {100, 0, -50, 88, 99, 33, -30};
        /*int max = getMax(new Supplier<Integer>() {
            @Override
            public Integer get() {
                int temp = arr[0];
                for (int i = 0; i < arr.length; i++) {
                    if (temp < arr[i]) {
                        temp = arr[i];
                    }
                }
                return temp;
            }
        });*/
        int max = getMax(() -> {
            int temp = arr[0];
            for (int i = 0; i < arr.length; i++) {
                if (temp < arr[i]) {
                    temp = arr[i];
                }
            }
            return temp;
        });
        System.out.println("最大值为:" + max);
    }

    public static int getMax(Supplier<Integer> sup) {
        return sup.get();
    }
}
